<template>
  <div class="contentWrapper">
    <!--中间内容-->
    <main class="contentWrapperList">
      <section>
        <div class="shopCartListCon" v-for="(goods, index) in shopCart" :key="goods.id">
          <div class="left">
            <a href="javascript:;" class="cartCheckBox" :checked="goods.checked"></a>
          </div>
          <div class="center">
            <img :src="goods.small_image" alt="">
          </div>
          <div class="right">
            <a href="#">{{ goods.name }}</a>
            <div class="bottomContent">
              <p class="shopPrice"></p>
              <div class="shopDeal">
              </div>
            </div>
          </div>
        </div>
      </section>
    </main>
  </div>
</template>

<script>
import { mapState } from 'vuex';

export default {
  data() {
    return {
      cartsId: [],
      cartslist: []
    }
  },
  computed: {
    ...mapState('shopcart', ['cart'])
  },
  created() {
    this.cart = JSON.parse(JSON.stringify(cart)),
      this.getGoodList()
  },
  mounted() { this.getGoodsData() },
  methods: {
    getCartsData() {
      then(this.getGoodsDataSucc)
    },
    getGoodsList() {
      this.cart.forEach(item => {
        this.goodslist.push(item)
      })
      console.log(this.goodslist)
    },
    getGoodsDataSucc(res) {//获取成功后,将内容放入全局data内
      res = res.data
      if (res) {
        this.goodslist = res.filter
          (item => item.id.includes(this.cart.getItem.id));
        console.log(goodslist)
      }
    }
  }
}
</script>

<style scoped>
.contentWrapper {
  padding-top: 3.5rem;
}

/*列表内容*/
.contentWrapperList {
  padding-bottom: 6rem;
}

.contentWrapperList section {
  background-color: #fff;
}

.cartCheckBox {
  background: url("./images/shop-icon.png") no-repeat;
  -webkit-background-size: 2.5rem 5rem;
  background-size: 2.5rem 5rem;
  width: 1rem;
  height: 1rem;
}

.cartCheckBox[checked] {
  background-position: -1.2rem 0;
}

.shopCartListCon {
  display: flex;
  height: 6rem;
  border-bottom: 0.01rem solid #e0e0e0;
  margin-bottom: 0.7rem;
  padding: 0.5rem 0;
}

.shopCartListCon .left {
  /*background: purple;*/
  flex: 1;
  display: flex;
  /*justify-content: center;*/
}

.shopCartListCon .left a {
  display: inline-block;
  margin-top: 0.8rem;
  margin-left: 0.5rem;
}

.shopCartListCon .center {
  /*background: blue;*/
  flex: 3;
}

.shopCartListCon .center img {
  width: 100%;
  height: 100%;
}

.shopCartListCon .right {
  /*background: orangered;*/
  flex: 6;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  margin-left: 0.5rem;
  margin-right: 0.5rem;

  position: relative;
}

.shopCartListCon .right a {
  height: 2.2rem;
  line-height: 1.2rem;
  overflow: hidden;
  margin-bottom: 0.3rem;
  font-size: 0.8rem;
  color: #000;
}

.shopCartListCon .bottomContent {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
}

.shopCartListCon .bottomContent .shopPrice {
  font-size: 0.8rem;
}

.shopCartListCon .right .shopDeal span {
  display: inline-block;
  width: 1rem;
  height: 1.2rem;
  line-height: 1.2rem;
  text-align: center;
  float: left;
}

.shopCartListCon .right .shopDeal input {
  float: left;
  width: 2rem;
  height: 1.2rem;
  text-align: center;
  margin: 0 0.2rem;
  font-size: 0.8rem;
}
</style>
